<?php
namespace Application\Controllers;

class News extends \Library\Controller\Controller
{
	
	public function indexAction()
	{
		if (MOD_TRACE && MOD_TRACE_CLASS_Application_Controllers_News)
			var_dump("namespace Application\Controllers; class News -> public function indexAction()");
		$news = new \Application\Models\News("localhost");
		$this->setDataView(array("news" => $news->fetchAll()));
		
		$resultNews = $news->fetchAll();
		$title = (!empty($resultNews)?"All news":"news not found");
		$this->setDataView(array(	"news" => $resultNews,
									"pageTitle" => $title));
	}
	
	public function readAction($id = 0)
	{
		if (MOD_TRACE && MOD_TRACE_CLASS_Application_Controllers_News)
			var_dump("namespace Application\Controllers; class News -> public function readAction($id = 0)");
		$news = new \Application\Models\News("localhost");
		$resultNews = $news->findByPrimary($id);
		$title = (!empty($news)?$resultNews[0]->titre:"news not found");
		$this->setDataView(array("news" => $resultNews));
	}
}